/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var fieldLabel = new Array('A类','B类','C类','D类','D类城市','D类农村');
var fieldLabel1 = new Array('单位名称','已设测点数','应设测点数','覆盖率（%）'
                                     ,'已设测点数','应设测点数','覆盖率（%）'
                                     ,'已设测点数','应设测点数','覆盖率（%）'
                                     ,'已设测点数','应设测点数','覆盖率（%）'
                                     ,'首端已设测点数','首端应设测点数','覆盖率（%）','末端已设测点数','末端应设测点数','覆盖率（%）'
                                     ,'首端已设测点数','首端应设测点数','覆盖率（%）','末端已设测点数','末端应设测点数','覆盖率（%）'
                                     ,'已设测点数','应设测点数','综合覆盖率（%）');
var fieldName=new Array("orgName","A","PA","ARate"
                                 ,"B","PB","BRate"
                                 ,"C","PC","CRate"
                                 ,"D","PD","DRate"
                                 ,"DCS","PDCS","DCSRate","DCE","PDCE","DCERate"
                                 ,"DNS","PDNS","DNSRate","DNE","PDNE","DNERate"
                                 ,"total","PTotal","totalRate",'rn');
var _pageSize=20;


var store=new Ext.data.JsonStore({    
    url: "../../../servlet/system/PointLoad",
    root: 'data',
    idProperty: 'id',
    totalProperty: 'count',
    fields: fieldName,
    autoLoad: true,
    baseParams:{reportStatus:reportStatus,cmd:'number2',start:0,limit:99999,dateTo:new Date().format('Ym')}
});

var centercolumnModel = new Ext.grid.ColumnModel({
    columns: [
    {header: '序号',width: 40, dataIndex: 'rn', align: 'center'},    
    {
        header: fieldLabel1[0], 
        width: 100, 
        dataIndex: fieldName[0], 
        align: 'center'
    },
    {
        header: fieldLabel1[1], 
        width: 100, 
        dataIndex: fieldName[1], 
        align: 'center'
    },

    {
        header: fieldLabel1[2], 
        width: 100, 
        dataIndex: fieldName[2], 
        align: 'center'
    },

    {
        header: fieldLabel1[3], 
        width: 100, 
        dataIndex: fieldName[3], 
        align: 'center'
    },

    {
        header: fieldLabel1[4], 
        width: 100, 
        dataIndex: fieldName[4], 
        align: 'center'
    },

    {
        header: fieldLabel1[5], 
        width: 100, 
        dataIndex: fieldName[5], 
        align: 'center'
    },

    {
        header: fieldLabel1[6], 
        width: 100, 
        dataIndex: fieldName[6], 
        align: 'center'
    },

    {
        header: fieldLabel1[7], 
        width: 100, 
        dataIndex: fieldName[7], 
        align: 'center'
    },
    {
        header: fieldLabel1[8], 
        width: 100, 
        dataIndex: fieldName[8], 
        align: 'center'
    },
    {
        header: fieldLabel1[9], 
        width: 100, 
        dataIndex: fieldName[9], 
        align: 'center'
    },

    {
        header: fieldLabel1[10], 
        width: 100, 
        dataIndex: fieldName[10], 
        align: 'center'
    },

    {
        header: fieldLabel1[11], 
        width: 100, 
        dataIndex: fieldName[11], 
        align: 'center'
    },

    {
        header: fieldLabel1[12], 
        width: 100, 
        dataIndex: fieldName[12], 
        align: 'center'
    },

    {
        header: fieldLabel1[13], 
        width: 100, 
        dataIndex: fieldName[13], 
        align: 'center'
    },

    {
        header: fieldLabel1[14], 
        width: 100, 
        dataIndex: fieldName[14], 
        align: 'center'
    },

    {
        header: fieldLabel1[15], 
        width: 100, 
        dataIndex: fieldName[15], 
        align: 'center'
    },
    {
        header: fieldLabel1[16], 
        width: 100, 
        dataIndex: fieldName[16], 
        align: 'center'
    },

    {
        header: fieldLabel1[17], 
        width: 100, 
        dataIndex: fieldName[17], 
        align: 'center'
    },

    {
        header: fieldLabel1[18], 
        width: 100, 
        dataIndex: fieldName[18], 
        align: 'center'
    },
     {
        header: fieldLabel1[19], 
        width: 100, 
        dataIndex: fieldName[19], 
        align: 'center'
    },
    {
        header: fieldLabel1[20], 
        width: 100, 
        dataIndex: fieldName[20], 
        align: 'center'
    },
    {
        header: fieldLabel1[21], 
        width: 100, 
        dataIndex: fieldName[21], 
        align: 'center'
    },

    {
        header: fieldLabel1[22], 
        width: 100, 
        dataIndex: fieldName[22], 
        align: 'center'
    },

    {
        header: fieldLabel1[23], 
        width: 100, 
        dataIndex: fieldName[23], 
        align: 'center'
    },

    {
        header: fieldLabel1[24], 
        width: 100, 
        dataIndex: fieldName[24], 
        align: 'center'
    },
    {
        header: fieldLabel1[25], 
        width: 100, 
        dataIndex: fieldName[25], 
        align: 'center'
    },

    {
        header: fieldLabel1[26], 
        width: 100, 
        dataIndex: fieldName[26], 
        align: 'center'
    },

    {
        header: fieldLabel1[27], 
        width: 100, 
        dataIndex: fieldName[27], 
        align: 'center'
    },

    {
        header: fieldLabel1[28], 
        width: 100, 
        dataIndex: fieldName[28], 
        align: 'center'
    }
    ],
    defaultSortable: true,
    rows: [
    [
    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        header: fieldLabel[0], 
        colspan: 3, 
        align: 'center'
    },

    {
        width: 100, 
        header: fieldLabel[1], 
        colspan: 3, 
        align: 'center'
    },

    {
        width: 100, 
        header: fieldLabel[2], 
        colspan: 3, 
        align: 'center'
    },

    {
        width: 100, 
        header: fieldLabel[3], 
        colspan: 3, 
        align: 'center'
    },
    {
        width: 100, 
        header: fieldLabel[4], 
        colspan: 6, 
        align: 'center'
    },
    {
        width: 100, 
        header: fieldLabel[5], 
        colspan: 6, 
        align: 'center'
    }, 
    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        rowspan: 1
    }
    ] 
    ]
});

var now = new Date();

var dateTo = {
    xtype: 'datefield',
    id: 'DateTo',
    format: 'Y年m月',
    width: 150,
    value:now,
    listeners: {
        select: function(c, date) {            
            store.baseParams.dateTo = date.format('Ym');
        }
    }  
};

var centergrid=new Ext.grid.GridPanel({
    title: currentOrgName+' 覆盖率报表',
    store: store,
    colModel:centercolumnModel,
    enableColumnMove: false,
    viewConfig: {
        forceFit: false
    },
    plugins: [new Ext.ux.plugins.GroupHeaderGrid()],
    loadMask: true,
    tbar: new Ext.Toolbar([
        reportCombo,
        rangeCombo,
        {
        text: "时间：", 
        xtype: 'label', 
        style: {
            marginLeft: '20px'
        }
     },
     dateTo,
    searchButton,
    '-',
    {
        xtype: 'button',
        text: '导出',
        iconCls: 'icon-excel',
        width: 60,
        style: {
            marginLeft: '20px'
        },
        handler: downloadExcel
    }
    ]),
    bbar: new Ext.PagingToolbar({
        pageSize: _pageSize,
        store: store,
        displayInfo: true,
        displayMsg: '显示记录：{0} - {1}   总记录：{2}',
        emptyMsg:  '目前没有信息'
    })
});

function downloadExcel(){
    
    store.baseParams.type=42;
    var encodeParams = Ext.urlEncode(store.baseParams);
    open('../../../servlet/common/ExcelFileCreate?' + encodeParams);
}

function buildWindow(){
    var applicationUI = new Ext.Viewport({
        layout:'fit',
        items: [
        centergrid
        ]
    });
    if(reportStatus ===1){
        //Ext.getCmp('ReportStatus').setVisible(false);
        Ext.getCmp('ReportStatus').setValue(1);
    }
}
Ext.onReady(buildWindow); 

